// src/router/index.js
import { createRouter, createWebHistory } from 'vue-router';

// 导入组件
import AdminGoods from '@/views/admin/AdminGoods.vue';
import AdminNews from '@/views/admin/AdminNews.vue';
import AdminUser from '@/views/admin/AdminUser.vue';
import AdminHome from '@/views/admin/Home.vue';
import LoginVue from '@/views/Login.vue';
import RegisterVue from '@/views/Register.vue';
import UserInfoVue from '@/views/user/UserInfo.vue';
import AdminOrder from '@/views/admin/AdminOrder.vue';
import AdminLocation from '@/views/admin/AdminLocation.vue';
import AdminComment from '@/views/admin/AdminComment.vue';
import AdminLocationRecord from '@/views/admin/AdminLocationRecord.vue';
import UserMall from '@/views/front/UserMall.vue';
import UserDetail from '@/views/front/UserDetail.vue';
import UserCart from '@/views/front/UserCart.vue';
import UserOrder from '@/views/front/UserOrder.vue';

// 定义路由关系
const routes = [
    { path: '/', component: LoginVue },
    { path: '/register', component: RegisterVue },
    {
        path: '/admin', component: AdminHome, children: [
            { path: '/admin/news', component: AdminNews },
            { path: '/admin/goods', component: AdminGoods },
            { path: '/admin/order', component: AdminOrder },
            { path: '/admin/location', component: AdminLocation },
            { path: '/admin/locationRecord', component: AdminLocationRecord },
            { path: '/admin/comment', component: AdminComment },
            { path: '/admin/info', component: UserInfoVue },
            { path: '/admin/mall', component: UserMall },
            { path: '/front/detail', component: UserDetail },
            { path: '/front/cart', component: UserCart },
            { path: '/front/order', component: UserOrder },
            { path: '/admin/user', component: AdminUser }
        ]
    }
];

// 创建路由器
const router = createRouter({
    history: createWebHistory(),
    routes: routes
});

// 导出路由
export default router;